# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

opt_out_usage

default_platform(:android)

platform :android do
  desc "Runs all the tests"
  lane :test do
    gradle(task: "test", gradle_path: "../gradlew")
  end

  desc "Deploy a new version to the Google Play beta track"
  lane :deploy do
    gradle(
        task: "clean :app-k9mail:assembleRelease",
        build_type: "Release",
        flavor: "google",
        gradle_path: `../gradlew`,
        print_command: false,
        flags: "--no-build-cache --no-configuration-cache",
        properties: {
            "android.injected.signing.store.file" => ENV["K9MAIL_KEYSTORE_PATH"],
            "android.injected.signing.store.password" => ENV["K9MAIL_KEYSTORE_PASS"],
            "android.injected.signing.key.alias" => ENV["K9MAIL_KEYSTORE_WALLET_ALIAS"],
            "android.injected.signing.key.password" => ENV["K9MAIL_KEYSTORE_WALLET_PASS"],
        }
    )
    upload_to_play_store(
        track: "beta",
        skip_upload_images: true,
        skip_upload_screenshots: true,
        skip_upload_apk: false,
        validate_only: true,
    )
  end
end
